//****************************************************************************
// @Project Includes
//****************************************************************************
#include "REGXC888.H"
#include "CAN_BUS_DEFINES.H"
#include "TYPEDEF.H"
#include "MAIN.H"
#include "INT.H"
#include "CAN.H"
#include "CAN_TRANCIEVE.H"
#include "TIMER.H"
#include "ADC.H"
#include "PORTS.H"
#include "CONTROL_MATRIX.H"
//****************************************************************************
// @Function      void main(void) 
//
//----------------------------------------------------------------------------
// @Description   This is the main function.//
//****************************************************************************
uint8_t coounter = 0;

void main(void)
{
  	MAIN_vInit();

	init_ports();		// Initialisierung von IN-SAG typischen In/Outputs
	
	T01_vStartTmr(0);	// Start des Timers

/*==============================================================================================================================*/
/*=============================================USERCODE=========================================================================*/
/*==============================================================================================================================*/
  /* function of programm */
  /* Test for Recieving
	 Baudrate: 500kBaud
	 */				   
	recieve_msg_controll_init(0x300);		   
//	recieve_msg_controll_init(0x100);
//	recieve_msg_controll_init(0x104);
	
  	while(1)
	{
	coounter++;
	}

} //  End of function main







/*==============================================================================================================================*/
/*=============================================DO NOT TOUCH=====================================================================*/
/*==============================================================================================================================*/
//****************************************************************************
// @Function      void MAIN_vInit(void) 
//
//----------------------------------------------------------------------------
// @Description   This function initializes the microcontroller. It is 
//                assumed that the SFRs are in their reset state.
//****************************************************************************
void MAIN_vInit(void)
{
  	//   FCLK runs at 2 times the frequency of PCLK.
	SFR_PAGE(_su1, noSST);         // switch to page1

  	CMCON         =  0x10;         // load Clock Control Register

  	SFR_PAGE(_su0, noSST);         // switch to page0
  	///  Initialization of module 'Interrupt Unit'
  	//	INT_vInit();
  	///  Initialization of module 'MultiCAN Controller '


	T01_vInit();
	
	ADC_vInit();

	CAN_vInit();
  	///  Initialization of  'CAN interrupts'
	CANinterrupt_Init();

  	//   Interrupt Priority
	IP            =  0x02;         // load Interrupt Priority Register
	IPH           =  0x00;         // load Interrupt Priority High Register
	IP1           =  0x01;         // load Interrupt Priority 1 Register
	IPH1          =  0x00;         // load Interrupt Priority 1 High Register
	//   globally enable interrupts
	EA            =  1;  

	

	
} //  End of function MAIN_vInit

																		   